<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Bob's Auto Parts - Oder Results</title>
    </head>
    <body>
        <h1>Bob's Auto Parts</h1>
        <h2>Oder Results</h2>
        <?php
            //创建变量用于存放表单内容
            $tireqty = $_POST['tireqty'];
            $oilqty = $_POST['oliqty'];
            $sparkqty = $_POST['sparkqty'];
            //回显内容
            echo "<p>Oder processed at ";
            echo date('H:i, jS F Y');
            echo "</p>";
            /*
            echo '<p>Your order is as follows: </p>';
            echo $tireqty. ' tires<br />';
            echo $oilqty. ' bottles of oil<br />';
            echo $tireqty. ' spark plugs<br />';
            */
            $totalqty = 0;
            $totalamount = 0.00;
            $totalqty = $tireqty +  $oilqty + $sparkqty;
            echo "Items ordered :" . $totalqty. "<br />";

            //定义常量 define
            define('TIREPRICE', 100);
            define('OILPRICE', 10);
            define('SPARKPRICE', 4);

            $totalamount = $tireqty * TIREPRICE
                         + $oilqty * OILPRICE
                         + $sparkqty * SPARKPRICE;
            //number_format($totalamount,2) 格式化， xxx.xx 格式
            echo "Subtotal: $". number_format($totalamount,2). "<br />";
            $taxrate = 0.10; //稅
            $totalamount = $totalamount * (1 + $taxrate);
            echo "Total including tax : $ ". number_format($totalamount,2). "<br />";
            /*
            echo 'isset($tireqty):'. isset($tireqty). '<br />';
            echo 'isset($nothere):'. isset($nothere). '<br />';
            echo 'empty($tireqty):'. empty($tireqty). '<br />';
            echo 'empty($nothere):'. empty($nothere). '<br />';
            */
         ?>
    </body>
</html>
